//package 几个重要的接口;
//
//import java.util.Arrays;
//import java.util.Comparator;
//
///**
// * Created with IntelliJ IDEA.
// * Description:
// * User: lenovo
// * Date: 2022-07-01
// * Time: 18:24
// */
//class Student{
//    public String name;
//    public int age;
//    public double score;
//
//    public Student(String name, int age, double score) {
//        this.name = name;
//        this.age = age;
//        this.score = score;
//    }
//
//    @Override
//    public String toString() {
//        return "Student{" +
//                "name='" + name + '\'' +
//                ", age=" + age +
//                ", score=" + score +
//                '}';
//    }
//}
////比较器
//class AgeComparator implements Comparator<Student>{
//    @Override
//    public int compare(Student o1, Student o2) {
//        return o1.age-o2.age;
//    }
//}
//class ScoreComparator implements Comparator<Student>{
//
//    @Override
//    public int compare(Student o1, Student o2) {
//        return (int)(o1.score-o2.score);
//    }
//    class NameComparetor implements Comparator<Student>{
//
//        @Override
//        public int compare(Student o1, Student o2) {
//            return o1.name.compareTo(o2.name);
//        }
//    }
//}
//public class Test0 {
//    public static void main(String[] args) {
//        Student[] student = new Student[3];
//        //每一个数组元素都是一个学生对象
//        student[0] = new Student("小王",19,85.0);
//        student[1] = new Student("小李",17,75.0);
//        student[2] = new Student("小刘",18,95.0);
//        System.out.println("排序前"+ Arrays.toString(student));
//        AgeComparator ageComparator = new AgeComparator();
//        //Arrays.sort(student, new AgeComparator());
//        Arrays.sort(student,ageComparator);
//        System.out.println("排序后"+Arrays.toString(student));
//        System.out.println("================");
//        System.out.println("排序前"+ Arrays.toString(student));
//       ScoreComparator scoreComparator = new ScoreComparator();
//        Arrays.sort(student,scoreComparator);
//        System.out.println("排序后"+Arrays.toString(student));
//
//
//    }
//
//
//
//
//        public static void main1(String[] args) {
//        Student student = new Student("小王",19,85.0);
//        Student student1 = new Student("小李",18,90.0);
//        //比较age
//        AgeComparator ageComparator = new AgeComparator();
//        int ret = ageComparator.compare(student,student1);
//            System.out.println(ret);
//            //比较score
//            ScoreComparator scoreComparator = new ScoreComparator();
//            int ret0 = scoreComparator.compare(student,student1);
//            System.out.println(ret0);
//
//    }
//}
